Tryit Editor v2.3

Edit This Code:
<!DOCTYPE html> <html> <head> <script src="../../ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script> <script> $(document).ready(function(){ $("button").click(function(){ $("p").offsetParent().css("background-color","red"); }); }); </script> </head> <body> <button>Set background-color</button> <div style="border:1px solid black;width:70%;position:absolute;left:10px;top:50px"> <div style="border:1px solid black;margin:50px;background-color:yellow"> <p>Click button to set the background color of the first positioned parent element of this paragraph.</p> </div></div> </body> <!-- Mirrored from www.w3schools.com/jquery/tryit.asp?filename=tryjquery_css_offsetparent by HTTrack Website Copier/3.x [XR&CO'2014], Fri, 23 Jan 2015 08:15:37 GMT --> </html>
Result:
Try it Yourself - © w3schools.com